﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Register Src="../Shared/Header.ascx" TagName="Header" TagPrefix="uc1" %>
<!DOCTYPE html>
<html>
<head runat="server">
    <title>物品交接记录</title>
    <uc1:Header ID="Header1" runat="server" />
    <script type="text/javascript" language="javascript">
        $(function () {
            $('#grid').datagrid({
                iconCls: 'icon-save',
                nowrap: false,                      //数据是否显示在一行里
                striped: true,                      //奇偶行使用不同背景色
                url: '/Package/FLoadAllPackgeView/',           //从远程站点请求数据的 URL
                fitColumns: true,                   //适应表格的宽度并且防止水平滚动
                singleSelect: true,                //是否允许选中一行
                pagination: false,                  //分页
                rownumbers: true,                   //行号
                columns: [[
                     { field: 'BaoBH', title: '包编号', width: 80, hidden: true }
                    , { field: 'BaoMC', title: '包名称', width: 80 }
                    , { field: 'KuCL', title: '库存量(个)', width: 80,
                        formatter: function (value, rowData, rowIndex) {
                            return '<span style="color:Red; font-size:14pt; font-weight:bolder;" >' + value + '</span>';
                        }
                    }
                    , { field: 'WeiGHSL', title: '未归还数量(个)', width: 80,
                        formatter: function (value, rowData, rowIndex) {
                            return '<input type="button" style="color:blue;font-size:14pt; font-weight:bolder;" value="' + value + '" onclick="noReturn(\'' + rowData.BaoBH + '\',\'' + rowData.WeiGHSL + '\')" />';
                        }
                    }
                    , { field: 'DuiHSL', title: '兑换数量(个)', width: 80,
                        formatter: function (value, rowData, rowIndex) {
                            return '<span style="color:black; font-size:14pt; font-weight:bolder;" >' + value + '</span>';
                        }
                    }
                ]]
            });
        });
        function submit() {
            $('#form').form('submit', {
                onSubmit: function () {
                    return $(this).form('validate');
                },
                success: function (msg) {
                    var msg1 = eval('(' + msg + ')');
                    if (msg1.IsSuccess) {
                        $.messager.alert('提示', "保存成功", 'info', function () {
                            $('#win').dialog('close');
                            $('#grid').datagrid('reload');
                        });
                    }
                    else {
                        $.messager.alert('提示', msg1.Message, "error");
                    }
                },
                error: function () {
                    $.messager.alert('错误', '保存失败！', "error");
                }
            });
        }

        function showdate(n) {
            var uom = new Date();
            uom.setDate(uom.getDate() + n);
            uom = uom.getFullYear() + "-" + (uom.getMonth() + 1) + "-" + uom.getDate();
            return uom;
        }

        function TiaoMH_onchange(tmh) {
            $.getJSON("/Package/GetMBaoMC/" + tmh, function (data) {
                $("#BaoMC").val(data.text);
                $("#BaoMC1").val(data.id);
                if (data.id != null && data.id.toString() != "") {
                    $('#grid').datagrid("reload");
                }
            });
        }

        function inventorys() {
            $('#win').dialog({
                title: '库存物品列表',
                iconCls: 'icon-search',
                width: 820,
                height: 500,
                closed: false,
                cache: false,
                href: '/Package/FInventorys/',
                modal: true,
                resizable: true,
                onLoad: function () {
                    $('#grid_inventorys').datagrid({
                        iconCls: 'icon-save',
                        nowrap: true,                      //数据是否显示在一行里
                        striped: true,                      //奇偶行使用不同背景色
                        url: '/Package/FLoadAllInventorys/',           //从远程站点请求数据的 URL
                        fitColumns: true,                   //适应表格的宽度并且防止水平滚动
                        singleSelect: true,                //是否允许选中一行
                        pagination: false,                  //分页
                        rownumbers: true,                   //行号
                        onLoadSuccess: function (data) {
                            var totle = eval(data).total
                            $("#sp_inventorys").text(totle);
                        }
                    });
                    $("#north_inventorys").parent().css("overflow-y", "auto");

                }
            });
        }

        function noReturns() {
            $('#win').dialog({
                title: '未归还物品列表',
                iconCls: 'icon-search',
                width: 820,
                height: 500,
                closed: false,
                cache: false,
                href: '/Package/FNoReturns/',
                modal: true,
                resizable: true,
                onLoad: function () {
                    $('#grid_noReturns').datagrid({
                        iconCls: 'icon-save',
                        nowrap: true,                      //数据是否显示在一行里
                        striped: true,                      //奇偶行使用不同背景色
                        url: '/Package/FLoadAllNoReturns/',           //从远程站点请求数据的 URL
                        fitColumns: true,                   //适应表格的宽度并且防止水平滚动
                        singleSelect: true,                //是否允许选中一行
                        pagination: false,                  //分页
                        rownumbers: true,                   //行号
                        onLoadSuccess: function (data) {
                            var totle = eval(data).total
                            $("#sp_noReturns").text(totle);
                        }
                    });
                    $("#north_noReturns").parent().css("overflow-y", "auto");
                }
            });
        }

        function noReturn(BaoBH, WeiGHSL) {
            if (WeiGHSL.toString() == "0") {
                $.messager.alert('提示', "该包已归还！", 'info');
            }
            else {
                $('#win').dialog({
                    title: '未归还物品列表',
                    iconCls: 'icon-search',
                    width: 820,
                    height: 500,
                    closed: false,
                    cache: false,
                    href: '/Package/FNoReturns/' + BaoBH,
                    modal: true,
                    resizable: true,
                    onLoad: function () {
                        $('#grid_noReturns').datagrid({
                            iconCls: 'icon-save',
                            nowrap: true,                      //数据是否显示在一行里
                            striped: true,                      //奇偶行使用不同背景色
                            url: '/Package/FLoadAllNoReturns/' + BaoBH,           //从远程站点请求数据的 URL
                            fitColumns: true,                   //适应表格的宽度并且防止水平滚动
                            singleSelect: true,                //是否允许选中一行
                            pagination: false,                  //分页
                            rownumbers: true,                   //行号
                            onLoadSuccess: function (data) {
                                var totle = eval(data).total
                                $("#sp_noReturns").text(totle);
                            }
                        });
                        $("#north_noReturns").parent().css("overflow-y", "auto");
                    }
                });
            }
        }  
    </script>
    <style type="text/css">
        .panel, .panel-body
        {
            overflow-x: hidden;
            overflow-y: auto;
        }
    </style>
</head>
<body class="easyui-layout">
    <div region="center" style="padding: 5px;" border="false">        
        <table id="grid" toolbar="#toolbar">
        </table>
        <div id="toolbar" style="padding: 2px; height: auto">
            <a id="btnInventory " class="easyui-linkbutton" href="javascript:void(0)" iconcls="icon-search" plain="true" onclick="inventorys()">库存物品明细</a>
            <a id="btnNoReturn" class="easyui-linkbutton" href="javascript:void(0)" iconcls="icon-search" plain="true" onclick="noReturns()">未归还物品明细</a>
        </div>
    </div>
    <div id="win" />
</body>
</html>
